import request from '@/utils/request'
import type {
  loginPostReq,
  loginPasswordApi,
  loginPasswordReq,
  codeGetApi,
  codeGetReq,
  patientMyUserApi,
  patientMylistApi,
  patientAddReq,
  patientUpdateReq,
  patientConsultOrderListReq,
  patientConsultOrderListApi,
  loginThirdpartyReq,
  codeBindGetReq,
  codeBindGetApi,
  loginBindingReq
} from '@/types/user'

// 密码登录接口调用
export const loginPassword = (data: loginPasswordReq) =>
  request<loginPasswordApi>('/login/password', 'post', data)

// 手机验证码获取
export const codeGet = (data: codeGetReq) => {
  return request<codeGetApi>('/code', 'get', data)
}
// 手机验证码登录
export const loginPost = (data: loginPostReq) => request<loginPasswordApi>('/login', 'post', data)

// 获取用户信息
export const patientMyUser = () => request<patientMyUserApi>('/patient/myUser', 'get')

// 获取家庭档案列表
export const patientMylist = () => request<patientMylistApi>('/patient/mylist')

// 新增患者
export const patientAdd = (data: patientAddReq) => request('/patient/add', 'post', data)

// 编辑患者
export const patientUpdate = (data: patientUpdateReq) => request('/patient/update', 'put', data)

// 删除患者
export const patientDel = (id: string) => request(`/patient/del/${id}`, 'delete')

// 总诊列表
export const patientConsultOrderList = (data: patientConsultOrderListReq) =>
  request<patientConsultOrderListApi>('/patient/consult/order/list', 'get', data)

// 取消订单
export const patientOrderCancel = (id: string) => request(`/patient/order/cancel/${id}`, 'put')

// 删除订单
export const patientOrder = (id: string) => request(`/patient/order/${id}`, 'delete')

// 第三方登录
export const loginThirdparty = (data: loginThirdpartyReq) =>
  request<loginPasswordApi>('/login/thirdparty', 'post', data)

// 绑定手机号验证码获取
export const codeBindGet = (data: codeBindGetReq) => request<codeBindGetApi>('/code', 'get', data)

// 绑定
export const loginBinding = (data: loginBindingReq) =>
  request<loginPasswordApi>('/login/binding', 'post', data)
